home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2006 December / PCWDEC06.iso / Software / Trial / Paint Shop Pro XI / Data1.cab / _941BA3BB7DF4471DB5474E3FD0383E4F < prev    next >
Encoding:
Text File  |  2006-08-04  |  3.8 KB  |  87 lines

  1. from PSPApp import *
  2. import PSPUtils
  3.  
  4. def ScriptProperties():
  5.     return {
  6.         'Author': u'Corel Corporation',
  7.         'Copyright': u'Copyright (c) 2002-2006 Corel Corporation. All rights reserved.',
  8.         'Description': "Merge the selected objects into the first object selected rewind the contours.",
  9.         'Host': u'Paint Shop Pro 9',
  10.         'Host Version': u'9.00'
  11.     }
  12.  
  13.  
  14. def Do(Environment):
  15.     # get the set of selected objects
  16.     Result = App.Do( Environment, 'ReturnVectorObjectProperties', {'GeneralSettings': {'Version': ((9,0,0),1) }} )
  17.     ObjList = Result['ListOfObjects']
  18.  
  19.     # use list comprehension to get a list of all the regular objects and all the text
  20.     # objects.  We don't care about the text objects, but if any exist we can't do the
  21.     # merge
  22.     if ObjList is not None:
  23.         MergeableObjects = [ Obj for Obj in ObjList if Obj['ObjectData'] is not None ]
  24.         TextExObjects = [ Obj for Obj in ObjList if Obj['TextExData'] is not None ]
  25.         TextObjects = [ Obj for Obj in ObjList if Obj['TextData'] is not None ]
  26.         RectangleObjects = [ Obj for Obj in ObjList if Obj['RectangleData'] is not None ]
  27.         EllipseObjects = [ Obj for Obj in ObjList if Obj['EllipseData'] is not None ]
  28.         SymmetricShapeObjects = [ Obj for Obj in ObjList if Obj['SymmetricShapeData'] is not None ]
  29.     else:
  30.         App.Do(Environment,  'MsgBox', {
  31.                     'Buttons': App.Constants.MsgButtons.OK, 
  32.                     'Icon': App.Constants.MsgIcons.Info, 
  33.                     'Text': PSPUtils.TwoOrMoreMsg,
  34.                                         'GeneralSettings': {
  35.                                             'Version': ((9,0,0),1)
  36.                                             }
  37.                     })
  38.         return
  39.  
  40.     x = 0
  41.     if len(TextExObjects) > 0:
  42.         x = 1
  43.     elif len(TextObjects) > 0:
  44.         x = 1
  45.     elif len(RectangleObjects) > 0:
  46.         x = 1
  47.     elif len(EllipseObjects) > 0:
  48.         x = 1
  49.     elif len(SymmetricShapeObjects) > 0:
  50.         x = 1
  51.     if x:
  52.         App.Do( Environment, 'ConvertToPath', {'GeneralSettings': {'Version': ((9,0,0),1) }} )
  53.         Result = App.Do( Environment, 'ReturnVectorObjectProperties', {'GeneralSettings': {'Version': ((9,0,0),1) }} )
  54.         ObjList = Result['ListOfObjects']
  55.         if ObjList is not None:
  56.             MergeableObjects = [ Obj for Obj in ObjList if Obj['ObjectData'] is not None ]
  57.     if len(MergeableObjects) < 2:
  58.         App.Do(Environment,  'MsgBox', {
  59.                     'Buttons': App.Constants.MsgButtons.OK, 
  60.                     'Icon': App.Constants.MsgIcons.Info, 
  61.                     'Text': PSPUtils.TwoOrMoreMsg,
  62.                                         'GeneralSettings': {
  63.                                             'Version': ((9,0,0),1)
  64.                                             }
  65.                     })
  66.         return
  67.  
  68.     # delete all the selected objects
  69.     App.Do( Environment, 'ClearSelection', {'GeneralSettings': {'Version': ((9,0,0),1) }} )
  70.  
  71.     # Create the base object by taking the first thing in the mergeable list
  72.     App.Do( Environment, 'AddGroupsAndObjects', {'ListOfObjects': [MergeableObjects[0]],
  73.                                                      'GeneralSettings': {'Version': ((9,0,0),1) }} )
  74.  
  75.     # now add all the other objects - we could rewind the contours after every object, but
  76.     # there is a performance penalty to doing so, so we only put the windpath parameter
  77.     # on the last object in the list.
  78.     for Obj in MergeableObjects[1:-1]: # take everything after the first object    
  79.         App.Do( Environment, 'NodeEditAddPath', { 'Path': Obj['ObjectData']['Path'],'WindPath': App.Constants.Boolean.false,
  80.                                                           'GeneralSettings': {'Version': ((9,0,0),1) }})
  81.         
  82.     # on the last object set the winding flag so that nested objects become cutouts
  83.     Obj = MergeableObjects[-1]
  84.     App.Do( Environment, 'NodeEditAddPath', { 'Path': Obj['ObjectData']['Path'],'WindPath': App.Constants.Boolean.true,
  85.                                                   'GeneralSettings': {'Version': ((9,0,0),1) } })
  86.  
  87.